<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>RegExp</title>
</head>
<body>
    <form action="" onsubmit="return check();">
       密码: <input type="text" id="pwd" name="pwd"><span id="pwd_span" style="color: red"></span><br>
        <input type="submit" value="注册">
    </form>
</body>
<script>
    function check(){
        let pwdVal =document.getElementById("pwd").value;
        let reg1=/^[0-9a-z]{6}$/;
        let reg2=/\w+/;
        let reg3=/[a-z]+/;


        if (reg1.test(pwdVal)&&reg2.test(pwdVal)&&reg3.test(pwdVal)){
            //提交表单
            return true;
        }else {
            document.getElementById("pwd_span").innerHTML="密码长度为6，必须包含数字和字母";
            return false;
        }
    }
</script>
</html>